package com.skillscompetition.skillscompetition.controller;


import com.github.pagehelper.PageInfo;
import com.skillscompetition.skillscompetition.bean.GroupResults;
import com.skillscompetition.skillscompetition.bean.Ranking;
import com.skillscompetition.skillscompetition.common.ResponseType;
import com.skillscompetition.skillscompetition.service.impl.GroupResultsServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author lwg
 * @since 2019-11-09
 */
@RestController
@RequestMapping("group")
public class GroupResultsController {
    @Autowired
    private GroupResultsServiceImpl groupResultsService;

    //计算团体排名
    @GetMapping("sort")
    public Map<String, Object> sort() {
        groupResultsService.sort();
        return ResponseType.success(null);
    }

    /**
     * 团体排名列表
     *
     * @param page
     * @param pageSize
     * @return
     */
    @GetMapping
    public Map<String, Object> groupRankingList(@RequestParam(value = "page", defaultValue = "1") Integer page, @RequestParam(value = "pageSize", defaultValue = "3") Integer pageSize) {
        PageInfo<GroupResults> exam = groupResultsService.groupRankingList(page, pageSize);
        return ResponseType.success(exam);
    }
}
